var xmlHttp; //定义XMLHttpRequest对象
function createXmlHttpRequestObject() {
    //如果在internet Explorer下运行
    if (window.ActiveXObject) {
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            xmlHttp = false;
        }

    } else {
        //如果在Mozilla或其他的浏览器下运行
        try {
            xmlHttp = new XMLHttpRequest();
        } catch (e) {
            xmlHttp = false;
        }
    }
    //返回创建的对象或显示错误信息
    if (!xmlHttp)
        alert("返回创建的对象或显示错误信息");
    else
        return xmlHttp;
}
createXmlHttpRequestObject();
document.addEventListener('DOMContentLoaded', function () {
    var xqs = document.querySelectorAll('.opts.xq');
    xqs.forEach(function (xq) {
        xq.addEventListener('click', function () {
            var xq = document.querySelectorAll('.xq-info');
            if (xq.length > 0) {
                var xqParent = xq[0].parentElement;
                xqParent.removeChild(xq[0]);
            }
            divID = this.parentElement.id;
            var xqDiv = document.getElementById(divID);
            var casesID = xqDiv.querySelector('div').textContent;
            var box = document.createElement('div');
            box.className = 'xq-info';
            box.id = 'xq-info';
            xmlHttp.onreadystatechange = function () {
                if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                    xqDiv.parentNode.insertBefore(box, xqDiv.nextSibling);
                    var xqInfoDiv = document.getElementById("xq-info");
                    xqInfoDiv.innerHTML = xmlHttp.responseText;
                }
            } //判断URL调用的状态值并处理
            xmlHttp.open("GET", 'a_getPetCasesInfo.php?casesid=' + casesID, false);
            xmlHttp.send(null);
        });
    });
});

function removeBox() {
    var xq = document.querySelectorAll('.xq-info');
    var xqParent = xq[0].parentElement;
    xqParent.removeChild(xq[0]);
}